package cn.itcast.com.relection.fieldd;

import java.lang.reflect.Field;
import java.util.Arrays;

public class demo1 {
    public static void main(String[] args) throws NoSuchFieldException {
        //首先获取目标类的对象
        Class targetClass = FieldSon.class;

        System.out.println(Arrays.toString(targetClass.getFields()));

        System.out.println(Arrays.toString(targetClass.getDeclaredFields()));

        System.out.println(targetClass.getField("public_field").getName());
    }
}
class FieldFather{
    public int father;
}
class FieldSon extends FieldFather{
    public int public_field;
    protected double  protected_field;
    char default_field;
    private String private_filed;
}